from selenium.webdriver.common.by import By
from selenium import webdriver
from Po.Page import Page

class Page2(Page):
    # 定位器
    # 向下滚动1000像素
    # def scrollTo_1000(self):
    #     self.scrollTo_x()
# 1、点击地址管理
    aress_loc=(By.XPATH,'/html/body/div[5]/div[1]/div[2]/div[4]/div[2]/ul/li[1]/a')
    def aress(self):
        self.click(self.aress_loc)
    # 2、添加地址
    add_loc=(By.XPATH,'/html/body/div[5]/div[2]/div/div[1]/a')
    def add(self):
        self.click(self.add_loc)
    #断言
    # bj_loc=(By.CLASS_NAME,'layui-layer-title')
    # def bj(self):
    #     return self.text(self.bj_loc)
    # 3、所在地址 选择省份

    sf_loc=(By.CSS_SELECTOR,'/html/body/div[8]/div[2]/div/div/form/div[1]/div[1]/div/div/input')
    sfbj = (By.XPATH,'//*[@id="layui-layer7"]/div[2]/div/div/form/div[1]/div[1]/div/dl/dd[2]')
    def sf(self):
        self.click(self.sf_loc)
        self.click(self.sfbj)
    # 4、所在地址 选择市区
    sq_loc = (By.XPATH, '/html/body/div[8]/div[2]/div/div/form/div[1]/div[2]/div/div/input')
    sqbj = (By.XPATH,'//*[@id="layui-layer7"]/div[2]/div/div/form/div[1]/div[2]/div/dl/dd[2]')
    def sq(self):
        self.click(self.sq_loc)
        self.click(self.sqbj)
    # 5、所在地址 选择区域

    qy_loc = (By.XPATH, '//*[@id="layui-layer7"]/div[2]/div/div/form/div[1]/div[3]/div/div/input')
    qybj = (By.XPATH,'//*[@id="layui-layer7"]/div[2]/div/div/form/div[1]/div[3]/div/dl/dd[2]')
    def qy(self):
        self.click(self.qy_loc)
        self.click(self.qybj)
    # 6、输入收货人姓名  name="accept_name"
    accname_loc = (By.NAME, 'accept_name')
    def accname(self):
        self.send_keys(self.accname_loc,'郭瑞淇')
    # 7、输入手机号
    mobile_loc = (By.NAME, 'mobile')
    def mobile(self):
        self.send_keys(self.mobile_loc,'13381144084')
    # 8、输入街道地址
    address_loc=(By.NAME,'address')
    def address(self):
        self.send_keys(self.address_loc,'南大街')
    # 点击立即提交
    tijiao_loc=(By.XPATH,'//*[@id="layui-layer1"]/div[2]/div/div/form/div[6]/div/button[1]')
    def tijiao(self):
        self.click(self.tijiao_loc)

    guo_loc = (By.XPATH, '/html/body/div[5]/div[2]/div/div[2]/table/tbody/tr[6]/td[1]')

    def guo(self):
        return self.text(self.guo_loc)